﻿#pragma once
#include <signal.h>
#include "receiver.h"
#include "define.h"
#include <param.hpp>
#include "../util/sliding_list.hpp"

class lr_trend : public lt::trend, public lt::bar_receiver
{

public:
	
	lr_trend(lt::sigid_t id, lt::engine& engine,const lt::param& p):
		trend(id,engine),
		_code(p.get<code_t>("code")),
		_period(p.get<uint32_t>("period")),
		_current_trend(lt::trend_action_type::TACT_INVALID)
	{
	};


	~lr_trend(){};


public:

	/*
		 *	初始化事件
		 *	生命周期中只会回调一次
		 */
	virtual void on_init(lt::subscriber& suber) override;

	/*
	 *	销毁
	 */
	virtual void on_destory(lt::unsubscriber& unsuber) override;
	/*
	 *	bark推送
	 */
	virtual void on_bar(const bar_info& tick_info) override;


private:
	
	code_t _code ;

	uint32_t _period;

	lt::trend_action_type _current_trend;

};

